Skip to content

fix: reject LLM calls with incompatible contexts - #34

Closed
mikemikimike wants to merge 1 commit into
sqliteai:mainfrom
mikemikimike:fix/context-kind-mismatch
Closed

fix: reject LLM calls with incompatible contexts#34
mikemikimike wants to merge 1 commit into
sqliteai:mainfrom
mikemikimike:fix/context-kind-mismatch

Conversation

@mikemikimike

Copy link
Copy Markdown

Summary / Problem

Closes #33. llm_text_generate() and llm_embed_generate() only checked whether a context existed, so calling one with the other operation's context could silently return an empty result or run against incompatible state.

Changes

  • Track whether each llama context is for text generation, embeddings, or chat.
  • Reject text/embedding generation calls when the active context kind does not match, returning SQLITE_MISUSE with an actionable error.
  • Add a regression test covering both mismatch directions.

Tests

  • git diff --check — passed.
  • Docker-based C test compilation was attempted with Alpine Linux, but the container's package installation stalled without output in the available environment; the C test binary and full test suite were not run.

Compatibility / Known limitations

Valid calls retain their existing behavior. This changes an invalid context/operation combination from a silent result to an explicit SQLITE_MISUSE error. The full model-backed test suite remains to be run in an environment with the repository's native toolchain and test model dependencies.

@andinux

andinux commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Thanks for the PR, and for picking up #33.

We went with a slightly different approach — deriving the context kind from how the context is actually configured, rather than from which llm_context_create_* wrapper created it — so I'm closing this without merging. The replacement landed in #35, and the commit that closes #33 is 7173444 — released in 1.0.8.

@andinux andinux closed this Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

llm_text_generate() returns '' with no error when the active model/context is an embedding one

2 participants